package com.example.myapplication;


import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Random;

public class DetailActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);

        Intent intent = getIntent();
        String contactName = intent.getStringExtra("contact");

        // 生成随机QQ号
        Random random = new Random();
        StringBuilder qqNumber = new StringBuilder();
        for (int i = 0; i < 11; i++) {
            qqNumber.append(random.nextInt(10));
        }

        // 构建签名和动态信息
        String signature = "签名: " + contactName + "的签名";
        String dynamic = "动态: " + contactName + "的动态信息";

        // 设置TextView文本
        TextView contactTextView = findViewById(R.id.contactTextView);
        contactTextView.setText("联系人: " + contactName);

        TextView qqTextView = findViewById(R.id.qqTextView);
        qqTextView.setText("QQ号: " + qqNumber.toString());

        TextView signatureTextView = findViewById(R.id.signatureTextView);
        signatureTextView.setText(signature);

        TextView dynamicTextView = findViewById(R.id.dynamicTextView);
        dynamicTextView.setText(dynamic);

        // 设置返回按钮点击监听器
        Button backButton = findViewById(R.id.backButton);
        backButton.setOnClickListener(v -> finish());
    }
}